/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Marzo_3.Ej_25_03_13_02;

/**
 *
 * @author vesprada
 */
public class Color {
    
    private float r;
    private float g;
    private float b;

    final static Color ROJO_COLOR = new Color(1.0f, 0.0f, 0.0f);
    final static Color VERDE_COLOR = new Color(0.0f, 1.0f, 0.0f);
    final static Color AZUL_COLOR = new Color(0.0f, 0.0f, 1.0f);
    final static Color BLANCO_COLOR = new Color(1.0f, 1.0f, 1.0f);
    final static Color NEGRO_COLOR = new Color(0.0f, 0.0f, 0.0f);
    
    public Color(float r, float g, float b) {

        this.r = comprobar(r);
        this.g = comprobar(g);
        this.b = comprobar(b);
        
    }
    
    public static float comprobar(float color) {
        float aux;
        if (color < 0) {
            return 0;
        }
        else if (color > 1) {
            return 1;
        }
        else{
            return color;
        }
    }

    public float getR() {
        return r;
    }

    public void setR(float r) {
        this.r = comprobar(r);
    }

    public float getG() {
        return g;
    }

    public void setG(float g) {
        this.g = comprobar(g);
    }

    public float getB() {
        return b;
    }

    public void setB(float b) {
        this.b = comprobar(b);
    }
    
    public void gris(){
        float aux;
        aux = (this.getR() + this.getG() + this.getB())/3;
        this.setR(aux);
        this.setG(aux);
        this.setB(aux);
    }
    public void filtro(float cR,float cG,float cB){
        this.setR(comprobar(cR*this.getR()));
        this.setG(comprobar(cG*this.getG()));
        this.setB(comprobar(cB*this.getB()));
    }
    
    
    
}

